﻿using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Mvc;
using Neocean.Mpa.Authorization;
using Neocean.Mpa.Controllers;
using Neocean.Mpa.MusicStore;
using Neocean.Mpa.MusicStore.Dto;
using Neocean.Mpa.Web.Models.MusicStore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Neocean.Mpa.Web.Controllers
{
    [AbpMvcAuthorize(PermissionNames.Pages_Movies)]
    public class MovieController : MpaControllerBase
    {
        private readonly IMovieAppService _movieAppService;

        public MovieController(IMovieAppService movieAppService)
        {
            _movieAppService = movieAppService;
        }

        public async Task<IActionResult> Index()
        {
            var movies = (await _movieAppService.GetAll(new MovieCriteria())).Items;
            //var permissions = (await _movieAppService.GetAllPermissions()).Items;
            var model = new MovieListViewModel
            {
                Movies = movies
                //Permissions = permissions
            };

            return View(model);
        }

        public async Task<ActionResult> EditRoleModal(int movieId)
        {
            //var output = await _movieAppService.GetRoleForEdit(new EntityDto(movieId));
            var output = await _movieAppService.Get(new EntityDto(movieId));
            var model = new EditMovieModalViewModel(output);

            return View("_EditRoleModal", model);
        }
    }
}
